package com.yanqu.road.logic.activity.foxcard.game.effect;

import com.yanqu.road.entity.activity.foxcard.FoxBaseCard;
import com.yanqu.road.entity.activity.foxcard.FoxHandCard;
import com.yanqu.road.logic.activity.foxcard.game.FoxCardGameLogic;
import com.yanqu.road.logic.activity.foxcard.game.FoxCardShowInfo;
import com.yanqu.road.logic.activity.foxcard.game.eFoxCardShowType;
import com.yanqu.road.logic.activity.foxcard.game.eFoxCardTriggerType;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 每增加/撕掉1张手牌，加效果
 * 类型|加筹码基础值|乘筹码基础值|加倍率基础值|乘倍率基础值|金币基础值
 */
public class FoxCardEffect27 extends FoxCardEffectBase {
    @Override
    protected void effectHandle(FoxCardGameLogic gameLogic, FoxHandCard handCard) {
        int type = Integer.valueOf(effectConfig.getParamsList().get(0));
        if ((type == 1 && triggerType == eFoxCardTriggerType.ADD && handCard != null) || (type == 2 && triggerType == eFoxCardTriggerType.REMOVE && handCard != null)) {
            if (effectCard.getEffectValues().isEmpty()) {
                List<Long> effectValues = new ArrayList<>();
                effectValues.add(0L);
                effectCard.setEffectValues(effectValues);
            }
            long level = effectCard.getEffectValues().get(0);
            level++;
            effectCard.getEffectValues().set(0, level);

            FoxCardShowInfo showInfo = gameLogic.newFoxShow(eFoxCardShowType.EFFECT_CARD_LV_UP.getValue());
            showInfo.setSettleCards(Collections.singletonList(effectCard));
            showInfo.setShowValue(1);

        } else if (triggerType == eFoxCardTriggerType.AFTER_SCORE) {
            long level = 0;
            if (effectCard.getEffectValues().size() > 0) {
                level = effectCard.getEffectValues().get(0);
            }
            List<FoxBaseCard> foxEffectCards = Collections.singletonList(effectCard);
            int addBaseScore = Integer.valueOf(effectConfig.getParamsList().get(1)) + Integer.valueOf(effectConfig.getUpgradeParamsList().get(0)) * (int) level;
            int addBaseScoreMulti = Integer.valueOf(effectConfig.getParamsList().get(2)) + Integer.valueOf(effectConfig.getUpgradeParamsList().get(1)) * (int) level;
            int addBaseMulti = Integer.valueOf(effectConfig.getParamsList().get(3)) + Integer.valueOf(effectConfig.getUpgradeParamsList().get(2)) * (int) level;
            int addBaseMultiMulti = Integer.valueOf(effectConfig.getParamsList().get(4)) + Integer.valueOf(effectConfig.getUpgradeParamsList().get(3)) * (int) level;
            int goldChange = Integer.valueOf(effectConfig.getParamsList().get(5)) + Integer.valueOf(effectConfig.getUpgradeParamsList().get(4)) * (int) level;

            gameLogic.addBaseScore(addBaseScore, foxEffectCards, null); //加基础筹码
            gameLogic.addBaseScoreMulti(addBaseScoreMulti, foxEffectCards, null); //当前基础筹码乘算
            gameLogic.addBaseMulti(addBaseMulti, foxEffectCards, null); //加基础倍率
            gameLogic.addBaseMultiMulti(addBaseMultiMulti, foxEffectCards, null); //当前基础倍率乘算
            gameLogic.goldChange(goldChange, foxEffectCards, null, triggerType); //加金币
        }

    }
}
